package org.Niu;

public class int2String {
    public static void main(String[] args) {
        int a;
        a = 10;
        System.out.println("a = " + a);
        // 1. int 转 String
        //1.1 常用
        String s = String.valueOf(a);
        System.out.println("s = " + s);

        //1.2
        String string = Integer.toString(a);

        //1.3
        System.out.println(a + "");

        //1.4
        String format = String.format("%d", a);
        System.out.println("format = " + format);

        //1.5
        String string1 = new StringBuilder().append(a).toString();
        System.out.println("string1 = " + string1);

        //1.6
        String string2 = new StringBuffer().append(a).toString();
        System.out.println("string2 = " + string2);

        //2. String 转 int
        //2.1
        System.out.println(Integer.parseInt(string2));
        //2.2 转化成Integer
        System.out.println(Integer.valueOf(string2));
        //2.3
        String bin = "1010";
        System.out.println(Integer.parseInt(bin, 2));


    }
}